package com.uton.rfidcontroller.view.activity;

import android.os.Bundle;

import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
import com.uton.rfidcontroller.R;
import com.uton.rfidcontroller.common.utils.LogUtil;

import org.reactivestreams.Subscriber;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.annotations.NonNull;
import io.reactivex.subscribers.ResourceSubscriber;

@Deprecated
public class RxDoingActivity extends RxAppCompatActivity {

    private int mInt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rx_doing);

        String[] abc = {"123", "456", "789", "101112"};

        getBase64(abc);
    }

    public void getBase64(String[] pathList) {

        List<String> testList = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            testList.add("测试数据" + i);
        }


       Subscriber<String> o = new ResourceSubscriber<String>(){

           @Override
           protected void onStart() {
               super.onStart();
           }

           @Override
            public void onNext(@NonNull String s) {
                LogUtil.d(s);
            }

            @Override
            public void onError(@NonNull Throwable e) {
                LogUtil.d("错误在" + Thread.currentThread().getName());
            }

            @Override
            public void onComplete() {
                LogUtil.d("结束在" + Thread.currentThread().getName());
            }
        };


//        Flowable
//                .fromIterable(testList)
//                .subscribeOn(Schedulers.io())
//                .filter(new Predicate<String>() {
//                    @Override
//                    public boolean test(@NonNull String s) throws Exception {
//                        return true;
//                    }
//                })
//                .map(new Function<String, String>() {
//                    @Override
//                    public String apply(@NonNull String s) throws Exception {
//                        LogUtil.d("转换Base64在" + Thread.currentThread().getName());
//                        return s + "   ***转换一次***";
//                    }
//                })
//                .map(new Function<String, String>() {
//                    @Override
//                    public String apply(@NonNull String s) throws Exception {
//                        LogUtil.d("第二次转换在" + Thread.currentThread().getName());
//                        return s + "   ***转换二次***";
//                    }
//                })
//                .filter(new Predicate<String>() {
//                    @Override
//                    public boolean test(@NonNull String s) throws Exception {
//                        if (s.contains("4")) {
//                            throw new NullPointerException();
//                        }
//                        return true;
//                    }
//                })
//                .compose(this.<String>bindToLifecycle())
//                .onErrorReturnItem("拦截错误后的替换字段!!")
//                .onBackpressureBuffer()
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(o);

    }


}
